import Mock from 'mockjs2'
import { builder } from '../util'

const info = (options) => {
  const userInfo = {
    'id': '4291d7da9005377ec9aec4a71ea837f',
    'name': '天野远子',
    'userName': 'admin',
    'department': '',
    'officePhone': '',
    'email': '5116@xmks.com',
    'schoolPhone': '18210389',
    'role': 2
  }
  // role
  // const roleObj = {
  //   'id': 'admin',
  //   'name': '管理员',
  //   'describe': '拥有所有权限',
  //   'state': 1
  // }

  // userInfo.role = roleObj
  return builder(userInfo)
}

const userList = () => {
  return builder([
    { 'key': '001',
      'userName': 'admin',
      'userState': '学科填报',
      'authority': '哲学',
      'department': '教务处'
    },
    { 'key': '002',
      'userName': '361786@qq.com',
      'userState': '学校填报',
      'authority': 'D000101大学建设进展情况写实',
      'department': '擦口水'
    },
    { 'key': '003',
      'userName': 'cdscd6@qq.com',
      'userState': '学校填报',
      'authority': 'D000101大学建设进展情况写实',
      'department': '菜市场'
    },
    { 'key': '004',
      'userName': '361786@qq.com',
      'userState': '学科填报',
      'authority': '哲学',
      'department': '小鲤鱼'
    }
  ])
}

const userDelete = () => {
  return builder({}, '删除成功')
}

Mock.mock(/\/api\/user\/info/, 'get', info)
Mock.mock(/\/api\/user\/edit/, 'post', builder({}))
Mock.mock(/\/api\/user\/list/, 'get', userList)
Mock.mock(/\/api\/user\/delete/, 'post', userDelete)
